{include file="public/header" /}

<div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding: 15px;">
        <h1>修改员工</h1>
        <form class="layui-form" method="post" action="<?= url('doedit') ?>">
            <input type="hidden" value="{$emp.Eno}" name="Eno">
            <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <input value="{$emp.Ename}" class="layui-input layui-input-inline" type="text" name="Ename">
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">年龄</label>
                <input value="{$emp.Eage}" class="layui-input layui-input-inline" type="text" name="Eage">
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">部门</label>
                <div class="layui-input-inline">
                    <select name="Edeptno">
                        {foreach name="depts" key="k" item="v"}
                        {if condition="$v.Dno eq $emp.Edeptno"}
                        <option selected value="{$v.Dno}">{$v.Dname}</option>
                        {else}
                        <option value="{$v.Dno}">{$v.Dname}</option>
                        {/if}
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">头像</label>
                <div class="layui-input-inline">
                    <button type="button" class="layui-btn" id="btn_upload">
                        <i class="layui-icon">&#xe67c;</i>上传图片
                    </button>
                    <input class="layui-input layui-input-inline" type="hidden" name="icon" id="icon">
                    <div id="show_img">
                        <img class="icon" src="{$emp.icon}">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">简介</label>
                <div class="layui-input-block">
                    <div id="desc">
                        {$emp.desc}
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">仅显示简介</label>
                <div class="layui-input-block">
                    <div>
                        {$emp.desc}
                    </div>
                </div>
            </div>

            <div id="submit" class="layui-form-item">
                <input onclick="window.history.back();" class="layui-btn layui-btn-primary" type="button" value="返回">
                <input class="layui-btn" type="submit" value="修改">
            </div>
        </form>
    </div>
</div>

<div class="layui-footer">
    <!-- 底部固定区域 -->
    © layui.com - 底部固定区域
</div>
</div>
<script src="__STATIC__/layui/layui.js"></script>
<script src="__STATIC__/js/jquery-1.12.4.min.js"></script>
<script src="//unpkg.com/wangeditor/release/wangEditor.min.js"></script>
<script>
    //JavaScript代码区域
    layui.use(['element', 'form', 'upload'], function(){
        var element = layui.element;

        //头像上传
        var upload = layui.upload;
        var uploadInst = upload.render({
            elem: '#btn_upload' //绑定元素
            ,url: "{:url('Upload/upload_pri')}" //上传接口,
            ,done: function(res){
                //上传完毕回调
                $('#icon').attr('value', res.data.name)
                $('#show_img').html("<img class='icon' src='" + res.data.path +"'>")
            }
            ,error: function(){
                //请求异常回调
            }
        });
    });

    var E = window.wangEditor
    var editor = new E('#desc')
    editor.customConfig.uploadImgServer = "{:url('Upload/upload')}"  // 上传图片到服务器
    editor.customConfig.uploadFileName = 'image'
    editor.create()
</script>
</body>
</html>
